package com.qdsg.ysg.doctor.ui.adapter.tree.provider;

import android.view.View;

import com.chad.library.adapter.base.entity.node.BaseNode;
import com.chad.library.adapter.base.provider.BaseNodeProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.qdsg.ysg.doctor.R;
import com.qdsg.ysg.doctor.entity.SecondNode;

import org.jetbrains.annotations.NotNull;

import java.util.Objects;

/**
 * @Description: java类作用描述
 * @Author: lzp
 * @CreateDate: 2023/12/20 14:26
 * @UpdateRemark: 更新说明
 */
public class SecondProvider extends BaseNodeProvider {

    @Override
    public int getItemViewType() {
        return 2;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_tree_second;
    }

    @Override
    public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data) {
        SecondNode entity = (SecondNode) data;
        helper.setText(R.id.tv_second_classify_name, entity.getTitle());
    }

    @Override
    public void onClick(@NotNull BaseViewHolder helper, @NotNull View view, BaseNode data, int position) {
        SecondNode entity = (SecondNode) data;
        if (entity.isExpanded()) {
            Objects.requireNonNull(getAdapter()).collapse(position);
        } else {
            Objects.requireNonNull(getAdapter()).expandAndCollapseOther(position);
        }
    }
}